package com.example.reactor.rsocket.controller;

import com.example.reactor.rsocket.config.MessageClient;
import com.example.reactor.rsocket.config.ReactiveNodeClient;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * @author zpMeng
 * @since 10/11/2024
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("rsocket/client")
public class InvokeClientController {

    private final MessageClient messageClient;
    private final ReactiveNodeClient reactiveNodeClient;

    @GetMapping
    public void test() {
        Flux<String> map = Flux.range(1, 10)
                .map(item -> "request " + item);

        reactiveNodeClient.multiParam("fm", map)
                .subscribe(System.out::println);
    }

    @GetMapping("2")
    public void test2() {
        Flux<String> map = Flux.range(1, 10)
                .map(item -> "request " + item);

        reactiveNodeClient.multiParam2("fm", map)
                .subscribe(System.out::println);
    }
}
